<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.wso2.carbon.registry.common.utils.RegistryUtil" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.utils.GetDocumentUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.EndpointBean" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.clients.TopicServiceClient" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.xsd.TagBean" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.xsd.AssociationBean" %>

<%
    String cPath = request.getParameter("path");
    EndpointBean bean;
    String tagString="";
    try {
        GetDocumentUtil getDocumentUtil = new GetDocumentUtil();
        bean = getDocumentUtil.getEndpointBean(cPath, config, session);

        TopicServiceClient client = new TopicServiceClient(config, session);
        TagBean[] tagBeans = client.getTags(cPath);

        if(tagBeans != null){
            for(TagBean tagBean:tagBeans){
                tagString += tagBean.getTagName() + ", ";
            }
            tagString = tagString.substring(0,tagString.length()-1);
        }
    } catch (UIException e) {
        %>Error occured while retrieving endpoint details<%
        return;
    } 
%>

<br/>
 
<form id="diaEditForm" >
<input type="hidden" name="path" value="<%=cPath%>"/>
<table width="50%">
<thead>
		<tr>
			<th colspan="2">
<strong>Edit Documentation</strong>
</th>
		</tr>
	</thead>
	<tbody>
    <tr><td class="leftCol-med">Document Title <span class="required">*</span></td>
        <td><input type="text" name="diaTitle" value="<%=bean.getTitle()%>"/></td>
    </tr>
    <tr>
          <td>Summary</td>
        <td><textarea rows="4" cols="20" name="diaSummary"><%=bean.getSummary()%></textarea></td>
    </tr>
    <tr>
        <td>External Link<span class="required">*</span></td>
        <td><input type="text" name="diaLink" value="<%=bean.getExternalLink()%>"/></td>
    </tr>
    <tr>
        <td>Related Documents</td>
        <td><input type="text" name="diaRelDoc1" value=""/></td>
    </tr>
    <tr>
        <td>Tags</td>
        <td><input type="text" name="diaTags" value="<%=tagString%>"/></td>
    </tr> 
    <tr> 
        <td colspan="2" class="buttonRow"><input class="button" value="Save" onclick="submitCustomViewUIForm('diaEditForm', '../registry/custom/dia/dia_edit_handler_ajaxprocessor.jsp')"/></td>
        <td></td>
    </tr>
       </tbody>
</table>
</form>

<br/>
